/*
 * @Author: new-wang
 * @Date: 2025-08-26 18:04:21
 * @LastEditors: new-wang
 * @LastEditTime: 2025-09-02 14:57:28
 * @FilePath: \nest-demo\src\module\system\user\user.module.ts
 * @Description: user module
 * forFeature() 方法来定义在当前作用域内注册了哪些存储库,有了它，
 * 我们可以使用 @InjectRepository() 装饰器将 UsersRepository 注入到 UsersService 中
 */
import { Module } from '@nestjs/common'
import { UserController } from './user.controller'
import { UserService } from './user.service'
import { TypeOrmModule } from '@nestjs/typeorm'
import { UserEntity } from 'src/entityAll/entities/sys-user.entity'
import { JwtModule } from '@nestjs/jwt'
import { ConfigModule, ConfigService } from '@nestjs/config'
import { UserLoginLogEntity } from 'src/entityAll/entities/UserLoginLog'
import { UserRoles as UserRolesEntity } from 'src/entityAll/entities/UserRoles'
import { RoleModule } from '../role/role.module'

@Module({
  imports: [
    RoleModule,
    TypeOrmModule.forFeature([UserEntity,UserLoginLogEntity,UserRolesEntity]),
    JwtModule.registerAsync({
      imports: [ConfigModule],
      useFactory: async (config: ConfigService) => ({
        secret: config.get('jwt.secretkey'),
      }),
      inject: [ConfigService],
    }),
  ],
  controllers: [UserController],
  providers: [UserService],
  exports: [UserService],
})
export class UserModule {}
